using System;
using System.Collections.Generic;
using SimpleJson;
using Pomelo.DotNetClient;
using UnityEngine;

public class MyPomeloMgr
{
    private static MyPomeloMgr _instance;
    public static MyPomeloMgr Instance
    {
        get {
            if(_instance == null){
                _instance = new MyPomeloMgr();
            }
            return _instance;
        }
    }
    private static Dictionary<string, MyPomelo> pomeloDict = null;

    private MyPomeloMgr()
    {
        if (pomeloDict == null) pomeloDict = new Dictionary<string, MyPomelo>();
    }
    public static MyPomelo GetPomelo(string _channelId,string userId = "123456")
    {
        Debug.Log(Utils.GetTimeStamp());
        var temp = Instance;
        var key = _channelId + "*" + userId ;
        var pomeloInstance = pomeloDict.GetValue(key, null);
        //不存在则新建
        if (pomeloInstance == null)
        {
            pomeloInstance = new MyPomelo(userId, _channelId, "115.159.204.72");
            pomeloDict.AddOrReplace(key, pomeloInstance);
            Debug.Log("加入字典");
        }
        return pomeloInstance;
    }

}
